 
export class MapInfo {
    public version:boolean = false;
    public x:number = 0;
    public y:number = 0;
    public links:Array<number> = null;
    public linksLength:number = 0;
    public parent:MapInfo = null;//MapInfo
    public nowCost:number = 0;
    public mayCost :number =  0;
    public next :MapInfo = null;//MapInfo
    public pre:MapInfo = null;//MapInfo
    public dist:number = 0; 
    constructor(nx:number,ny:number){
        this.x=nx;
        this.y=ny;
    }

    addLinks(obj,mapObj){
        this.links =[];
        if (this.x > 0) {
            this.addL((this.x - 1), this.y, obj, mapObj);
        }
        if (this.y > 0)
        {
            this.addL(this.x , (this.y - 1), obj, mapObj);
        }
        this.addL((this.x + 1), this.y, obj, mapObj);
        this.addL(this.x, (this.y + 1), obj,mapObj);
    } 

    addL(tx,ty,obj, mapObj){
        let id = ty + "*" + tx;
        if (mapObj[id] == null){
            if (obj[id]==null ){
                obj[id]=new MapInfo(tx, ty);
                this.links[this.links.length]=obj[id];
                this.linksLength++;
            }
        }
    }
   
}